/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package GUI.Dialogs;

import GUI.Components.BButton;
import GUI.Components.CancelButton;
import General.CurrentData;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;

/**
 *
 * @author David
 */
public class ExitDialog extends BasicDialog
{

    private JCheckBox dontBotherCheckBox = new JCheckBox("Don't bother me again");
    private JPanel buttonPanel = new JPanel();
    private BButton okButton = new BButton("Exit");
    private CancelButton cancelButton;

    /**
     *
     */
    public ExitDialog()
    {
        okButton.addActionListener(new ActionListener()
        {
            public void actionPerformed(ActionEvent e)
            {
                if (dontBotherCheckBox.isSelected())
                {
                    CurrentData.getConfiguration().getSettings().put("exitwithoutprompt", Boolean.TRUE.toString());
                }
                CurrentData.getConfiguration().save();
                System.exit(0);
            }
        });
        dontBotherCheckBox.setHorizontalAlignment(SwingConstants.CENTER);
        cancelButton = new CancelButton(this);
        setTitle("Exit");
        add(new JLabel("Do you want to exit? All unsaved data will be lost!", JLabel.CENTER), BorderLayout.NORTH);
        add(dontBotherCheckBox);
        buttonPanel.add(okButton);
        buttonPanel.add(cancelButton);
        add(buttonPanel, BorderLayout.SOUTH);
        pack();
        setAlwaysOnTop(true);
        setLocationRelativeTo(null);
        setVisible(true);
    }
}
